package com.gisuni.sddc.util;
import org.apache.commons.dbcp.BasicDataSource;
import org.nutz.dao.Dao;
import org.nutz.dao.impl.NutDao;
import org.nutz.dao.impl.SimpleDataSource;
import org.nutz.ioc.Ioc;
import org.nutz.ioc.impl.NutIoc;
import org.nutz.ioc.loader.json.JsonLoader;


/**
 * 公众类，公共操作
 */
public class OdbcCommon {
	
	private static Dao _gisdao;
	private static Ioc _configIoc;
	public static Dao getGISDao() {
		if (_gisdao == null) {
			try{
				SimpleDataSource ds = getConfigIco().get(SimpleDataSource.class,
						"dataSource");
				_gisdao = new NutDao(ds);
				ds.close();
			}catch (Exception e) {
				// TODO: handle exception
				 e.printStackTrace();  
			}
		
		}
		return _gisdao;
	}	
	public static Ioc getConfigIco() {
		if (_configIoc == null) {
			_configIoc = new NutIoc(new JsonLoader("conf/shinho.js"));
		}
		return _configIoc;
	}
}
